import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout/Layout.vue'
import './lib/repeatRoute'
import route from './lib/menuTransformRoute'
import staticRouter from './staticRouter'
Vue.use(VueRouter)
console.log(route)
const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/about',
    children: [
      ...route,
      ...staticRouter
    ]

  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404.vue')
  },
  {
    path: '*',
    redirect: '/404',
    meta: {}
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export const useRouter = () => router;
export const useRoute = () => router.currentRoute;

export default router
